Some of the routes in our Next.js applications throw a 500 Internal Server Error even when they exist and work in development mode.Link - Playground | Crio.Do | Build internship-grade projects in a real developer environment and accelerate your full stack or backend developer career with a job-ready project portfolio. Enroll and start for free.
If I visit the above link via some other link like our homepage or so (client side routing), then it opens up fine. But when I hit the URL directly, it fails.
image2726×960 351 KBPoints to note:
We don’t do SSG or SSR on any of our pages. It’s a plain vanilla next.js application.We don’t have any custom netlify functions.netlify.toml[build] command = "yarn run build" publish = ".next"[[plugins]] package = "@netlify/plugin-nextjs"yarn run build is basically next build4. next.config.js
const path = require('path');const withOptimizedImages = require('next-optimized-images');const { withSentryConfig } = require('@sentry/nextjs');const isProd = process.env.NODE_ENV === 'production';const { withPlaiceholder } = require('@plaiceholder/next');const withBundleAnalyzer = require('@next/bundle-analyzer')({ enabled: process.env.ANALYZE === 'true',});const moduleExports = withBundleAnalyzer( withOptimizedImages(withPlaiceholder({ images: {disableStaticImages: true, }, trailingSlash: true, basePath: "learn/v2", assetPrefix: "learn/v2", publicRuntimeConfig: {staticFolder: "learn/v2", }, optimizeImagesInDev: true, sassOptions: {includePaths: [path.join(__dirname, 'styles')], }, experimental: {removeConsole: isProd ? true : false, },}), ),);const SentryWebpackPluginOptions = { silent: true, // Suppresses all logs};module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);Deploy logs──────────────────────────────────────────────────────────────── Netlify Build ────────────────────────────────────────────────────────────────❯ Version @netlify/build 26.2.3❯ Flags {}❯ Current directory stage-crio❯ Config file stage-crio/netlify.toml❯ Context production❯ Loading plugins- @netlify/plugin-nextjs@4.2.3 from netlify.toml and package.json❯ Outdated plugins- @netlify/plugin-nextjs@4.2.3: latest version is 4.2.5 Migration guide: https://ntl.fyi/next-plugin-migration To upgrade this plugin, please update its version in "package.json"──────────────────────────────────────────────────────────────── 1. @netlify/plugin-nextjs (onPreBuild event) ────────────────────────────────────────────────────────────────Next.js cache restored.Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.(@netlify/plugin-nextjs onPreBuild completed in 1.6s)──────────────────────────────────────────────────────────────── 2. build.command from netlify.toml────────────────────────────────────────────────────────────────$ yarn run buildyarn run v1.22.17$ yarn startup$ node startup.js$ next buildwarn - You have enabled experimental feature(s).warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.info - Checking validity of types info - Collecting page data info - Generating static pages (26/26)info - Finalizing page optimization PageSize First Load JS┌ ○ /794 B379 kB├/_app0 B 378 kB├ ○ /404 (387 ms)5.19 kB 386 kB├ ○ /activities 75.4 kB 650 kB├ ○ /impersonate/[id]462 B441 kB├ ○ /login 5.4 kB 386 kB├ ○ /magic/[id] (385 ms)46.8 kB 641 kB├ ○ /me/[meId] 2.39 kB 766 kB252 B├ ○ /PSDS/playground (637 ms)12.1 kB12.3 kB 465 kB+ First Load JS shared by all378 kB ├ chunks/framework-eeba1b405d308ec4.js42.3 kB ├ chunks/main-53e0cba5d7770f8c.js 26.8 kB ├ chunks/pages/_app-3b8b53267a8228ec.js306 kB ├ chunks/webpack-4f6506a321871006.js 2.75 kB └ css/77e7be7280b21608.css11.6 kB○ (Static) automatically rendered as static HTML (uses no initial props)✨ Done in 141.64s.(build.command completed in 2m 21.8s)──────────────────────────────────────────────────────────────── 3. @netlify/plugin-nextjs (onBuild event) ────────────────────────────────────────────────────────────────Patching undefinedMoving static page files to serve from CDN...Moved 5 filesNetlify configuration property "redirects" value changed to [ {from: '/learn/v2/_next/static/*',to: '/static/:splat',status: 200 }, {from: '/_next/image/*',query: { url: ':url', w: ':width', q: ':quality' },to: '/learn/v2/_ipx/w_:width,q_:quality/:url',status: 301 }, {from: '/learn/v2/_ipx/*',to: '/.netlify/builders/_ipx',status: 200 }, {from: '/_next/static/image/*',to: '/static/image/:splat',status: 200 }, {from: '/learn/v2/cache/*',to: '/404.html',status: 404,force: true }, {from: '/learn/v2/server/*',to: '/404.html',status: 404,force: true }, {from: '/learn/v2/serverless/*',to: '/404.html',status: 404,force: true }, {from: '/learn/v2/traces',to: '/404.html',status: 404,force: true }, {from: '/learn/v2/routes-manifest.json',to: '/404.html',status: 404,force: true }, {from: '/learn/v2/build-manifest.json',to: '/404.html',status: 404,force: true }, {from: '/learn/v2/prerender-manifest.json',to: '/404.html',status: 404,force: true }, {from: '/learn/v2/react-loadable-manifest.json',to: '/404.html',status: 404,force: true }, {from: '/learn/v2/BUILD_ID',to: '/404.html',status: 404,force: true }, {from: '/learn/v2/api',to: '/.netlify/functions/___netlify-handler',status: 200 }, {from: '/learn/v2/api/*',to: '/.netlify/functions/___netlify-handler',status: 200 }, {from: '/learn/v2/favicon.ico',to: '/learn/v2/favicon.ico',conditions: { Cookie: [Array] },status: 200 }, {from: '/learn/v2/login-banner-desktop.png',to: '/learn/v2/login-banner-desktop.png',conditions: { Cookie: [Array] },status: 200 }, {from: '/learn/v2/login-banner-mobile.png',to: '/learn/v2/login-banner-mobile.png',conditions: { Cookie: [Array] },status: 200 }, {from: '/learn/v2/robots.txt',to: '/learn/v2/robots.txt',conditions: { Cookie: [Array] },status: 200 }, {from: '/learn/v2/vercel.svg',to: '/learn/v2/vercel.svg',conditions: { Cookie: [Array] },status: 200 }, {from: '/learn/v2/images/doodle-white.png',to: '/learn/v2/images/doodle-white.png',conditions: { Cookie: [Array] },status: 200 }, {from: '/learn/v2/*',to: '/.netlify/functions/___netlify-handler',status: 200,conditions: { Cookie: [Array] },force: true }, {from: '/learn/v2/_next/data/CBfHwQcumAqF7u6SOF_9j/index.json',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/_next/data/CBfHwQcumAqF7u6SOF_9j/404.json',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/404',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/_next/data/CBfHwQcumAqF7u6SOF_9j/PSDS/playground.json',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/PSDS/playground',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/_next/data/CBfHwQcumAqF7u6SOF_9j/activities.json',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/activities',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/_next/data/CBfHwQcumAqF7u6SOF_9j/login.json',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/login',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/_next/data/CBfHwQcumAqF7u6SOF_9j/not-found.json',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/not-found',to: '/.netlify/functions/___netlify-handler',status: 200,force: false },{from: '/learn/v2/_next/data/CBfHwQcumAqF7u6SOF_9j/impersonate/:id.json',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/impersonate/:id',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/_next/data/CBfHwQcumAqF7u6SOF_9j/magic/:id.json',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/magic/:id',to: '/.netlify/functions/___netlify-handler',status: 200,force: false }, {from: '/learn/v2/*',to: '/.netlify/functions/___netlify-handler',status: 200 }].(@netlify/plugin-nextjs onBuild completed in 777ms)──────────────────────────────────────────────────────────────── 4. Functions bundling ────────────────────────────────────────────────────────────────Packaging Functions from .netlify/functions-internal directory: - ___netlify-handler/___netlify-handler.js - ___netlify-odb-handler/___netlify-odb-handler.js - _ipx/_ipx.jsNo Functions were found in netlify/functions directory(Functions bundling completed in 1m 31.7s)──────────────────────────────────────────────────────────────── 5. @netlify/plugin-nextjs (onPostBuild event) ────────────────────────────────────────────────────────────────Next.js cache saved.(@netlify/plugin-nextjs onPostBuild completed in 1s)──────────────────────────────────────────────────────────────── Netlify Build Complete────────────────────────────────────────────────────────────────(Netlify Build completed in 3m 59s)I’m afraid sharing repo might not be feasible, but I am open to share any info that you may require in order to help us resolve